#include <sys/stat.h>
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>


int daemon_init()
{
  pid_t pid;
  if ((pid = fork())<0)
    return -1;
  else if (pid != 0)
    exit(0);

  /*char currentpath[260] = {0};
  getcwd(currentpath,260);*/
  setsid();
  chdir("/");
  umask(0);
  close(0);
  close(1);
  close(2);

  return 0;
}
